package net.cyndeline.componentSystem.gameplay

import net.cyndeline.entitySystem.AbstractEventHandlerSystem
import net.cyndeline.entitySystem.defaultImpl.Aspect
import net.cyndeline.events.gameplay.TakeAction
import net.cyndeline.components.agent.PlayerInput
import net.cyndeline.entitySystem.EntityRef
import net.cyndeline.entitySystem.Event

/**
 * Enables the player to perform a single action by enabling
 * the input receiver.
 */
class PlayerInputEnablerSystem extends AbstractEventHandlerSystem(
      new Aspect().getAll(classOf[PlayerInput]), classOf[TakeAction]){

  override def onEvent(event: Event, entity: EntityRef) {
    event match {
      case action: TakeAction => {
        val inputComponent = entity.getComponent(classOf[PlayerInput]).get
        val inputModule = inputComponent.player
        
        /* Enables the player to submit a single input. */
        inputModule.enableInput
      }
    }
  }
}